package com.example.demo04datamybatis.controller;

import com.example.demo04datamybatis.mapper.DepartmentMapper;
import com.example.demo04datamybatis.pojo.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class DeptController {

    @Autowired
    private DepartmentMapper departmentMapper;

    @GetMapping(path = "/dept/{id}")
    public Department getDepartment(@PathVariable Integer id) {
        Department dept = departmentMapper.getDeptById(id);
        return dept;
    }

    @PostMapping(path = "/dept")
    public Department insertDepartment(Department department) {
        departmentMapper.insertDept(department);
        return department;
    }
}
